03. CODE: The RoutePlanner Header
The RoutePlanner Header
You are now ready to begin filling out the RoutePlanner
class, which will contain methods and data to perform the A* search on the RouteModel
data. A class stub and empty class constructor have been provided in the route_planner.h
and route_planner.cpp
files. In this exercise, you will be starting with the header file route_planner.h
. Note that RoutePlanner
already has the private RouteModel
reference m_Model
. This will refer to the model that you will be performing A* search on.
## To complete this exercise:
- Add the following private variables to the
RoutePlanner
class inroute_planer.h
:RouteModel::Node
pointersstart_node
andend_node
. These will point to the nodes in the model which are closest to our starting and ending points.- A float
distance
. This variable will hold the total distance for the route that A* search finds fromstart_node
toend_node
.
- Add the following public method to the
RoutePlanner
class inroute_planner.h
:- A
GetDistance()
method. This is a public getter method for thedistance
variable, and should just returndistance
. This method will later be used to print out the total distance frommain.cpp
.
- A
Note: This exercise has no tests associated with it, but there will be tests in future exercises using the RoutePlanner
class.
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: react
- Opened files (when workspace is loaded): n/a
-
userCode:
export CXX=g++-7
export CXXFLAGS=-std=c++17
cmake_tests() {
/usr/local/bin/cmake -DTESTING="FindClosest" "$1"
}
export -f cmake_tests
Solution
RoutePlanner Header